// license-header java merge-point
/**
 * This is only generated once! It will never be overwritten.
 * You can (and have to!) safely modify it by hand.
 * TEMPLATE:    SpringServiceImpl.vsl in andromda-spring cartridge
 * MODEL CLASS: tsaditiro::com.systemsjr.tsaditiro::attribute::service::AttributeService
 * STEREOTYPE:  Service
 */
package com.systemsjr.tsaditiro.attribute.service;

import com.systemsjr.tsaditiro.attribute.Attribute;
import com.systemsjr.tsaditiro.attribute.vo.AttributeSearchCriteria;
import com.systemsjr.tsaditiro.attribute.vo.AttributeVO;

import java.util.List;

/**
 * @see com.systemsjr.tsaditiro.attribute.service.AttributeService
 */
public class AttributeServiceImpl
    extends AttributeServiceBase
{

    /**
     * @see com.systemsjr.tsaditiro.attribute.service.AttributeService#saveAttribute(AttributeVO)
     */
    protected  AttributeVO handleSaveAttribute(AttributeVO attributeVO)
        throws Exception
    {
    	Attribute attribute = getAttributeDao().attributeVOToEntity(attributeVO);
    	if(attributeVO.getId() != null){
    		getAttributeDao().update(attribute);
    	} else{
    		attribute = getAttributeDao().create(attribute);
    	}
    	
    	return getAttributeDao().toAttributeVO(attribute);
    }

    /**
     * @see com.systemsjr.tsaditiro.attribute.service.AttributeService#loadAll()
     */
    protected  List handleLoadAll()
        throws Exception
    {
    	List l = (List) getAttributeDao().loadAll();
    	
    	return (List) getAttributeDao().toAttributeVOCollection(l);
    }

    /**
     * @see com.systemsjr.tsaditiro.attribute.service.AttributeService#deleteAttribute(AttributeVO)
     */
    protected  void handleDeleteAttribute(AttributeVO attributeVO)
        throws Exception
    {
    	if(attributeVO.getId() != null){
    		getAttributeDao().remove(attributeVO.getId());
    	}
    }

    /**
     * @see com.systemsjr.tsaditiro.attribute.service.AttributeService#searchAttributes(AttributeSearchCriteria)
     */
    protected  List handleSearchAttributes(AttributeSearchCriteria searchCriteria)
        throws Exception
    {
    	List l = getAttributeDao().findByCriteria(searchCriteria);
    	
    	return (List) getAttributeDao().toAttributeVOCollection(l);
    }

}